package com.atguigu.webrestfulcrud.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
public class LoginController {

    //进入我执欢迎页，地址是localhost
    @RequestMapping(value = "/")
    public String index() {
        return "login";
    }
    //登陆账户名密码检查，错的弹消息，对的跳转网页
    @RequestMapping("/console")
    public String login(@RequestParam("username")String username,
                        @RequestParam("password")String password,
                        Map<String,Object> map) {
        if ("hiwozhi".equals(password) &&"admin".equals(username)){
            return  "successzmq";
        }else if ("hiwozhi".equals(password))
            return "console";
        else
            map.put("msg","密码错误");
        return "login";
    }
}
